#include <AVUICommon.h>
#include <AVUIFrameworkElement.h>


class CNetrekClientListener;
class CGameWorld;
class CGameWorldEvent;

class DetailViewWindow : public AVUI::FrameworkElement
{
public:
    DetailViewWindow();
    ~DetailViewWindow();

    void ViewPlanet(DWORD dwPlanetID);

    DECLARE_ELEMENT(DetailViewWindow, AVUI::FrameworkElement);
    IMPLEMENT_ROUTED_EVENT(DetailItemChanged, AVUI::RoutedEventArgs, AVUI::RoutingStrategy::Direct);


    void set_GameWorld(CGameWorld* pGameWorld) { m_pGameWorld = pGameWorld; }

protected:
    AVUI::Size MeasureOverride(const AVUI::Size& constraintSize);
    AVUI::Size ArrangeOverride(const AVUI::Size& constraintSize);
    virtual void OnRender(AVUI::DrawingContext& drawingContext);

private:
    void OnLayoutUpdated(AVUI::Object* pSender, AVUI::EventArgs* pArgs);
    void UpdatePlanetText();
    void OnGameWorldEvent(CGameWorldEvent* pGameWorldEvent);
    DWORD GetPlanetColor(CPlanet* pPlanet);
    bool HasPlanetInfo(CPlanet* pPlanet);
    bool IsPlayerNear(CPlanet* pPlanet, CGamePlayer* pPlayer);
    bool IsBombing(CPlanet* pPlanet, CGamePlayer* pPlayer);
    bool IsTransporting(CPlanet* pPlanet, CGamePlayer* pPlayer);
    
    enum EViewType
    {
        eViewType_None,
        eViewType_Planet,
        eViewType_Player,
    };

    EViewType m_eViewType;
    DWORD m_dwIDView;

    CGameWorld* m_pGameWorld;

    Ogre::Camera* m_pCamera;
    Ogre::Viewport* m_pViewport;
    bool m_isRegisteredForLayoutUpdated;


    AVUI::TextBlock* m_pTitle;
    AVUI::TextBlock* m_pResources;

    CGameWorld::CEventSubscription* m_pEventSubscription;
};
